<template>
  <div class="my-tag" @dblclick="doubleCl">
    <input
      class="input"
      type="text"
      placeholder="输入标签"
      v-if="endt"
      v-model="tag"
      v-focut
      @blur="showInput"
      @keyup.enter="showInput"
    />
    <div class="text" v-else>{{ value ? value : '无标签' }}</div>
  </div>
</template>

<script>
export default {
  name: "MySon",
  props: {
    value: {
      type: String,
      require: true,
    },
  },
  data() {
    return {
      endt: false,
      tag: "",
    };
  },

  methods: {
    doubleCl() {
      this.endt = true;
      this.tag = this.value
    },
    showInput() {
      this.endt = false;
      this.$emit('input',this.tag)
    },
  },
};
</script>

<style lang="less">
.my-tag {
  cursor: pointer;
  .input {
    appearance: none;
    outline: none;
    border: 1px solid #ccc;
    width: 100px;
    height: 40px;
    box-sizing: border-box;
    padding: 10px;
    color: #666;
    &::placeholder {
      color: #666;
    }
  }
}
</style>
